# while: 当条件为True进入循环，当条件为False是循环结束

# 死循环
# while True:
#     print("111")


# 循环n次
i = 1
sum = 0
while i <= 100:
    print(i)

    sum += i

    # 累加
    i += 1

print(sum)

# 计算偶数的和
i = 1
sum = 0
while i <= 100:
    # 判断一个数是不是偶数
    if i % 2 == 0:
        sum += i
    # 累加
    i += 1

print(sum)

# break语句可以提前退出循环
# 计算偶数的和
i = 1
sum = 0
while i <= 100:
    # 判断一个数是不是偶数
    if i % 2 == 0:
        sum += i
    if sum > 1000:
        # 跳出循环
        break
    # 累加
    i += 1

print(sum)

# continue，跳过当前的这次循环，直接开始下一次循环
i = 0
while i <= 100:
    i += 1
    if i % 2 == 1:
        continue
    print(i)
